﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MCB.Reflection.Extensions;
using System.Collections.Concurrent;
using System.Reflection;
using System.Collections;

namespace MCB.Reflection.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Test a = new Test()
            {
                Id = 1,
                Name = "1",
                Dicks = new Dictionary<string,string>()
                {
                    { "fkd", "dsdf" }
                },
                Child = new Test()
                {
                    Id = 2,
                    Name = "vmdsl"
                },
                Tests = new List<Test>()
                {
                    new Test() { Name = "njfd", Id = 65 },
                    new Test() { Name = "567", Id = 77, Names = new List<string>() { "4","999"} }
                },
                Names = new List<string>()
                    {
                        "dck","scmsc","ffff","6kfv"
                    }
            };

            Console.Write(a.Print());
            Console.ReadLine();

            
        }

        public static string JSON(PrintFormatArguments args)
        {
            if (args.MemberInfo != null && args.Value!=null)
            {
                if (args.Type.Is<IEnumerable>() && !args.Type.Is<string>())
                    return (args.FormatType == WriteTypeEnum.WriteStart) ? "[" : "],";
                else if (!args.Type.IsSystemType())
                    return (args.FormatType == WriteTypeEnum.WriteStart) ? "{" : "},";
                else
                {
                    if (args.Index == null)
                        return string.Concat(((PropertyInfo)args.MemberInfo).Name, ":", args.Value.WrapString(), ",");
                    else
                        return string.Concat(args.Value.WrapString(), ",");
                }
            }
            else
                return string.Empty;
        }
    }
}
